﻿<UserControl x:Class="XamlHelpmeet.UI.Editors.ComboBoxEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cvtrs="clr-namespace:XamlHelpmeet.UI.Converters"
             xmlns:local="clr-namespace:XamlHelpmeet.UI.Editors"
             xmlns:utils="clr-namespace:XamlHelpmeet.UI.Utilities"
             Loaded="ComboBoxEditor_Loaded">
    <UserControl.Resources>

        <cvtrs:BindingModeEnumConverter x:Key="bindingModeEnumConverter" />

        <ObjectDataProvider x:Key="bindingModeDS"
                            MethodName="GetSortedEnumNames"
                            ObjectType="{x:Type utils:UIHelpers}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="BindingMode" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <Style TargetType="{x:Type StackPanel}">
            <Setter Property="Margin"
                    Value="0,10,0,0" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal">
            <TextBlock Width="50"
                       Text="Path" />
            <Grid>
                <TextBox x:Name="txtBindingPath"
                         Width="100"
                         VerticalAlignment="Top" />
                <ComboBox x:Name="cboBindingPath"
                          MinWidth="100"
                          VerticalAlignment="Top"
                          SelectedValuePath="Name"
                          Visibility="Collapsed">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>
        </StackPanel>

        <StackPanel Grid.Row="1"
                    Orientation="Horizontal">

            <TextBlock Width="50"
                       HorizontalAlignment="Left"
                       Text="Mode" />
            <ComboBox Width="Auto"
                      FontSize="10"
                      IsSynchronizedWithCurrentItem="True"
                      ItemsSource="{Binding Mode=OneWay,
                                            Source={StaticResource bindingModeDS}}"
                      SelectedValue="{Binding Path=BindingMode,
                                              Mode=TwoWay,
                                              Converter={StaticResource bindingModeEnumConverter}}" />
        </StackPanel>
    </Grid>
</UserControl>